<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>设备树</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<link  href="${pageContext.request.contextPath}/app/css/style.css" rel="stylesheet"  type="text/css"/>
    <link  href="${pageContext.request.contextPath}/operamasks-ui/themes/default/om-default.css" rel="stylesheet">
	<script src="${pageContext.request.contextPath}/app/js/jquery-1.7.min.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/operamasks-ui/ui/operamasks-ui.js" type="text/javascript"></script>
 <style type="text/css">
   .deviceTree{
     width : 220px;
   }
</style>
<script type="text/javascript">
$(document).ready(function() {
	    var rightTarget = self.parent.frames['mainFrame'];
	    if($.browser.msie && ($.browser.version == 8.0 || $.browser.version == 9.0)){
	    	   var h = $(self.parent.frames['mainFrame']).height()-35; 
	    	   $('#panle').parent().height(h);
	    	   $('#panle').height(h-10);
	       }
      	$('#reordeteTreeMunm').omTree({
      		dataSource : 'reOrDeTe!queryForDevice.do',
            widht : 220,
            onBeforeExpand : function(node){
            	var nodeDom = $("#"+node.nid);
            	if(nodeDom.hasClass("hasChildren") && nodeDom.children("ul").children().length == 0){
            		nodeDom.removeClass("hasChildren");
            		$.ajax({
                        url: 'reOrDeTe!queryForDevice.do?queryId='+node.id,
                        method: 'POST',
                        dataType: 'json',
                        success: function(data){
                            $("#reordeteTreeMunm").omTree("insert", data, node);
                        }
                    });
            	}
            	return true;
            },
            onClick : function(nodeData, event){
	          	  $('#root').removeClass('selected');
	          	  var id = nodeData.id;
	          	  if(id.substring(0,2) != 'te'){
	          	  var activTabId = rightTarget.$('#tabs').omTabs('getActivated'); //tab设置的id
	          	  var tabIndex = rightTarget.$('#tabs').omTabs('getAlter', activTabId); //按照从0开始的tab顺序号，工作平台永远是0
	          	  //调用页面的方法只需要执行rightTarget.***,***是页面定义的方法。页面定义方法的规则是
	          	  //function_${tabId}(nodeData){}，nodeData是所点击设备树节点
	          	  var fun = "rightTarget.frames['iframe_"+activTabId+"'].function_"+activTabId+"(nodeData)";
	          	  var fun1 = "rightTarget.document.getElementById('iframe_"+activTabId+"').contentWindow.function_"+activTabId+"(nodeData)";
	          	  if(tabIndex == 0){ //工作平台的单独处理
	          		rightTarget.findLocation(nodeData);
	          	  }if(tabIndex == 1){//监控平台
	          		rightTarget.totalAlarmLog(nodeData);
	          	  }else{
	          		  try{
	          			  try{
		             		  eval(fun);
	          			  }catch(e){}
	             		  eval(fun1);
	          		  }catch(e){
	          			 //抛弃异常
	          		  }
	          	  }
	            }
            }
      	});
});

</script>   
  </head>
  <body>
<div class="left_menu" style="width: 220px;">
     <dl id="panle">
     		<dt class="select_panle">设备菜单</dt>
     	     <dd style="display: block;">
     	     	<span class="folder rootFolder"><a href="#" class="selected" id="root">设备菜单</a></span>
		        <ul id="reordeteTreeMunm"></ul>
		     </dd>
	  </dl>
	</div>
  </body>
</html>
